# Copyright (C) 2017 Marco Barisione
#
# Released under the terms of the GNU LGPL license version 2.1 or later.

# pylint: skip-file

import sys

from distutils.core import setup

from karton import __version__

long_description = '''
Karton is a tool which can transparently run Linux programs on macOS,
a different Linux distro, or a different architecture.
To do this, you just need to tell Karton which distro to use, which
packages to install, and which directories to make accessible. This is
called an image.

Then you can run your commands inside the image just by adding
"karton run image-name" in front of your commands.

Underneath, Karton uses Docker to allow running programs and manage
semi-persistent containers.
'''.strip()

# https://pypi.python.org/pypi?%3Aaction=list_classifiers
classifiers = [
    'Development Status :: 3 - Alpha',
    'Environment :: Console',
    'Environment :: MacOS X',
    'Intended Audience :: Developers',
    'License :: OSI Approved :: GNU Lesser General Public License v2 or later (LGPLv2+)',
    'Natural Language :: English',
    'Operating System :: MacOS :: MacOS X',
    'Operating System :: POSIX :: Linux',
    'Programming Language :: Python :: 2.7',
    'Programming Language :: Python :: 3',
    'Topic :: Utilities',
]

config = {
    # Info about the package:
    'name': 'karton',
    'description': 'Run Linux programs on macOS, a different Linux distro, or a different architecture',
    'long_description': long_description,
    'version': __version__,
    'author': 'Marco Barisione',
    'author_email': 'marco@barisione.org',
    'url': 'https://github.com/karton/karton',
    'download_url': 'https://github.com/karton/karton',
    'license': 'LPGL 2.1 or later',
    'platforms': ['Linux', 'macOS'],
    'classifiers': classifiers,

    # Installation stuff:
    'packages': ['karton'],
    'scripts': ['scripts/karton'],
    'package_data': {
        '': [
            'container-code/command_runner.py',
            'container-code/session_runner.py',
            ],
        },
}

can_run = False
try:
    with open('MANIFEST.in') as manifest_in_file:
        first_line = manifest_in_file.readline().strip()
        if first_line == '# This file was generated by Makefile.':
            can_run = True
except:
    pass

if can_run:
    setup(**config)
else:
    sys.stderr.write(
        'No MANIFEST.in found (or it\'s invalid).\n'
        'Try running "make MANIFEST.in" first.\n')
    raise SystemExit(1)
